package com.snail.snailvr.views.fragments;

import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.MenuRes;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;

import com.snail.snailvr.R;
import com.snail.snailvr.utils.ToolbarUtil;

/**
 * Fragment需要Toolbar的继承此类
 * Created by snail on 16/4/21.
 */
public abstract class BaseToolbarFragment extends BaseFragment {

    protected abstract boolean onToolbarMenuItemClick(MenuItem item);

    protected void setupToolbar(Toolbar toolbar, @DrawableRes int navigationIcon,String title, @MenuRes int menuResId){
        setupToolbar(toolbar,R.color.common_toolbar_bg,R.color.tab_indicator_color,navigationIcon,title,menuResId);
    }
    protected void setupToolbar(Toolbar toolbar, String title, @MenuRes int menuResId){
        setupToolbar(toolbar,R.color.common_toolbar_bg,R.color.tab_indicator_color,R.drawable.ic_back,title,menuResId);
    }
    protected void setupToolbar(Toolbar toolbar, @ColorRes int toolbarBg, @ColorRes int toolbarTitleBg, @DrawableRes int navigationIcon, String title, @MenuRes int menuResId){
        if(toolbar!=null) {
            ToolbarUtil.setupToolbar(getActivity(), toolbar,toolbarBg,toolbarTitleBg, navigationIcon, title, menuResId);
            toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    return onToolbarMenuItemClick(item);
                }
            });
        }
    }
}
